package com.me.blood.frag;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.me.blood.R;
import com.me.blood.databinding.DlgFeedBinding;


public class FeedDlg extends FullScreenDlg implements View.OnClickListener {

    DlgFeedBinding binding;
    String msg;

    public FeedDlg setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        binding = DlgFeedBinding.inflate(inflater, container, false);
        binding.getRoot().setOnClickListener(v -> dismiss());
        binding.type0.setOnClickListener(this);
        binding.type1.setOnClickListener(this);
        binding.type2.setOnClickListener(this);
        binding.type3.setOnClickListener(this);
        return binding.getRoot();
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        int type;
        if (id == R.id.type0) {
            type = 0;
        } else if (id == R.id.type1) {
            type = 1;
        } else if (id == R.id.type2) {
            type = 2;
        } else {
            type = 3;
        }
        dismiss(true, type);
    }
}
